import java.util.Scanner;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/13
 * Time:17:36
 **/
public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s1 = sc.nextLine();
            String s2 = sc.nextLine();
            System.out.println(match(s1, s2, 0, 0));
        }
    }

    /**
     * 每日一题-字符串通配符
     *
     * @param s1 字符串1
     * @param s2 字符串2
     * @param c1
     * @param c2
     * @return 返回是否合法
     */
    public static boolean match(String s1, String s2, int c1, int c2) {
        if (c1 == s1.length() && c2 == s2.length()) {
            return true;
        }
        if (c1 == s1.length() || c2 == s2.length()) {
            return false;
        }
        if (s1.charAt(c1) == '?') {
            return match(s1, s2, c1 + 1, c2 + 1);
        } else if (s1.charAt(c1) == '*') {
            return match(s1, s2, c1 + 1, c2) || match(s1, s2, c1 + 1, c2 + 1) || match(s1, s2, c1, c2 + 1);
        } else if (s1.charAt(c1) == s2.charAt(c2)) {
            return match(s1, s2, c1 + 1, c2 + 1);
        } else {
            return false;
        }
    }
}
